﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2014/3/20 21:11:23
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Sector7.Medical.EntityType;
using Sector7.Framework.DB;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// <!-- The description about this class. -->
    /// </summary>
    public class InterviewTemplateItemDAO : DAOBase<T7_InterviewTemplateItem>, IInterviewTemplateItemDAO
    {
        #region ============================================== Public functions
        public List<T7_InterviewTemplateItem> ReadAll(int templateId)
        {
            var itemList = new List<T7_InterviewTemplateItem>();
            string sql = @"
                SELECT
                    *
                FROM
                    T7_InterviewTemplateItem
                WHERE
                    TemplateId = @TemplateId";

            using (DBHelper helper = new DBHelper())
            {
                var reader = helper.ExecuteQuery(sql,
                    DBUtil.CreateSqlParameter(templateId, "TemplateId"));

                while (reader.Read())
                {
                    var item = new T7_InterviewTemplateItem();
                    DBUtil.ReadData(reader, item);

                    itemList.Add(item);
                }
            }

            return itemList;
        }
        #endregion
    }
}
